home *** CD-ROM | disk | FTP | other *** search
- /* header for the xcmd detecting tones using the microphone */
-
- #ifndef __record_h__
- #define __record_h__
-
- #define kThreshold 127 /* threshold for the raw data */
- #define kFFTthreshold 6000 /* threshold for the fft output */
-
- #define kExtraMem 0x5000
- /* the buffersize must be a power of 2, this is to keep the cost of a division down */
- #define kBuffSize 16384
- #define kBuffSizePower 16 /* the power of 2, so 16 gives a buff size = 2^16 */
- #define kSampleSize 1 /* 1 byte */
- #define kNumsInSample 5 /* a guess of how many individual digits will be in a sample */
- #define kSampleDiv2 1024 /* the number of bytes that will go to the fft */
- #define kSample 2049 /* 2 times the number of bytes that will go to the fft */
- /* structure for a buffer */
- typedef struct {
- Handle buffer;
- Boolean full;
- long buffSize;
- short headerlength;
- } BuffInfo;
-
- /* structure for the global variable */
- typedef struct {
- BuffInfo *BuffArray; /* pointer to the array of Sound buffer pointers */
- int NumBuffers; /* size of the array */
- int Error; /* the callback routines (or other routines) error code */
- SPBPtr RecordRec; /* pointer to the currently Recording record */
- Boolean FullBuffer; /* True when the RecordRec is full */
- int RecordingBuff; /* the number of the buffer in the RecordRec */
- Boolean PlayAndRecord; /* machine is capable of both simultaneously? */
- Boolean Stereo; /* machine is capable of stereo? */
- Boolean Quit; /* are we in the process of quitting? */
- Boolean FirstTime; /* is this our first time after initialization? */
- long SoundRefNum; /* the reference number of the sound device */
- long double *fftData; /* the pointer to the array for the data in the fft */
- } gGlobalType;
-
- /* define error codes */
- #define kNoError -1
- #define kNoInput 1
- #define kGestaltFailed 2
- #define kOpeningDevice 3
- #define kGettingRate 4
- #define kMemory 5
- #define kBufSetup 6
- #define kCallbackError 7
- #define kStopRecord 8
- #define kRecord 9
- #define kBuffersFull 10
- #define kBadKey 'x'
-
- #define TestBit(l,b) ((l>>b)&0x01)
- #define Abs(x) ((x<0)?-(x):x)
-
- /* protypes */
- Handle SetUpSounds (Handle Buf, short *HeaderSize, Fixed sampRate);
- int findAvailableBuff();
- int initToneRecognize();
- pascal void myRecordCallback (SPBPtr inParamPtr);
- int finishToneRecognize();
- long toneRecognize(XCmdPtr paramPtr);
- char ParseBuff(BuffInfo buffer,XCmdPtr paramPtr);
- void nfft(long double data[],unsigned long nn,int isign);
- char findmax(long double data[],unsigned long Samples,XCmdPtr paramPtr);
- #endif